home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / layout / nsPresContext.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  25KB  |  784 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37. #ifndef nsPresContext_h___
  38. #define nsPresContext_h___
  39.  
  40. #include "nsISupports.h"
  41. #include "nsColor.h"
  42. #include "nsCoord.h"
  43. #include "nsAString.h"
  44. #include "nsCompatibility.h"
  45. #include "nsCOMPtr.h"
  46. #include "nsIPresShell.h"
  47. #include "nsRect.h"
  48. #include "nsIDeviceContext.h"
  49. #include "nsHashtable.h"
  50. #include "nsFont.h"
  51. #include "nsIWeakReference.h"
  52. #include "nsITheme.h"
  53. #include "nsILanguageAtomService.h"
  54. #include "nsIObserver.h"
  55. #include "nsITimer.h"
  56. #include "nsCRT.h"
  57. #include "nsIPrintSettings.h"
  58. #include "nsPropertyTable.h"
  59. #ifdef IBMBIDI
  60. class nsBidiPresUtils;
  61. #endif // IBMBIDI
  62.  
  63. struct nsRect;
  64.  
  65. class imgIRequest;
  66.  
  67. class nsIContent;
  68. class nsIDocument;
  69. class nsIFontMetrics;
  70. class nsIFrame;
  71. class nsFrameManager;
  72. class nsIImage;
  73. class nsILinkHandler;
  74. class nsStyleContext;
  75. class nsIAtom;
  76. class nsIEventStateManager;
  77. class nsIURI;
  78. class nsILookAndFeel;
  79. class nsICSSPseudoComparator;
  80. class nsIAtom;
  81. struct nsStyleStruct;
  82. struct nsStyleBackground;
  83.  
  84. #ifdef MOZ_REFLOW_PERF
  85. class nsIRenderingContext;
  86. #endif
  87.  
  88. #define NS_IPRESCONTEXT_IID   \
  89. { 0x96e4bc06, 0x8e72, 0x4941, \
  90.   {0xa6, 0x6c, 0x70, 0xee, 0x7d, 0x1b, 0x58, 0x21} }
  91.  
  92. enum nsWidgetType {
  93.   eWidgetType_Button      = 1,
  94.   eWidgetType_Checkbox    = 2,
  95.   eWidgetType_Radio            = 3,
  96.   eWidgetType_Text            = 4
  97. };
  98.  
  99. enum nsLanguageSpecificTransformType {
  100.   eLanguageSpecificTransformType_Unknown = -1,
  101.   eLanguageSpecificTransformType_None = 0,
  102.   eLanguageSpecificTransformType_Japanese
  103. };
  104.  
  105. // supported values for cached bool types
  106. const PRUint32 kPresContext_UseDocumentColors = 0x01;
  107. const PRUint32 kPresContext_UseDocumentFonts = 0x02;
  108. const PRUint32 kPresContext_UnderlineLinks = 0x03;
  109.  
  110. // supported values for cached integer pref types
  111. const PRUint32 kPresContext_MinimumFontSize = 0x01;
  112.  
  113. // IDs for the default variable and fixed fonts (not to be changed, see nsFont.h)
  114. // To be used for Get/SetDefaultFont(). The other IDs in nsFont.h are also supported.
  115. const PRUint8 kPresContext_DefaultVariableFont_ID = 0x00; // kGenericFont_moz_variable
  116. const PRUint8 kPresContext_DefaultFixedFont_ID    = 0x01; // kGenericFont_moz_fixed
  117.  
  118. // An interface for presentation contexts. Presentation contexts are
  119. // objects that provide an outer context for a presentation shell.
  120.  
  121. // hack to make egcs / gcc 2.95.2 happy
  122. class nsPresContext_base : public nsIObserver
  123. {
  124. public:
  125.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESCONTEXT_IID)
  126. };
  127.  
  128. class nsPresContext : public nsPresContext_base {
  129. public:
  130.   NS_DECL_ISUPPORTS
  131.   NS_DECL_NSIOBSERVER
  132.   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
  133.  
  134.   enum nsPresContextType {
  135.     eContext_Galley,       // unpaginated screen presentation
  136.     eContext_PrintPreview, // paginated screen presentation
  137.     eContext_Print         // paginated printer presentation
  138.   };
  139.  
  140.   nsPresContext(nsPresContextType aType) NS_HIDDEN;
  141.  
  142.   /**
  143.    * Initialize the presentation context from a particular device.
  144.    */
  145.   NS_HIDDEN_(nsresult) Init(nsIDeviceContext* aDeviceContext);
  146.  
  147.   /**
  148.    * Set the presentation shell that this context is bound to.
  149.    * A presentation context may only be bound to a single shell.
  150.    */
  151.   NS_HIDDEN_(void) SetShell(nsIPresShell* aShell);
  152.  
  153.  
  154.   NS_HIDDEN_(nsPresContextType) Type() const { return mType; }
  155.  
  156.   /**
  157.    * Get the PresentationShell that this context is bound to.
  158.    */
  159.   nsIPresShell* PresShell() const
  160.   {
  161.     NS_ASSERTION(mShell, "Null pres shell");
  162.     return mShell;
  163.   }
  164.  
  165.   nsIPresShell* GetPresShell() const { return mShell; }
  166.  
  167.   nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); } 
  168.   nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); } 
  169. #ifdef _IMPL_NS_LAYOUT
  170.   nsStyleSet* StyleSet() { return GetPresShell()->StyleSet(); }
  171.  
  172.   nsFrameManager* FrameManager()
  173.     { return GetPresShell()->FrameManager(); } 
  174. #endif
  175.  
  176.   /**
  177.    * Access compatibility mode for this context
  178.    *
  179.    * All users must explicitly set the compatibility mode rather than
  180.    * relying on a default.
  181.    */
  182.   nsCompatibility CompatibilityMode() const { return mCompatibilityMode; }
  183.   NS_HIDDEN_(void) SetCompatibilityMode(nsCompatibility aMode);
  184.  
  185.   /**
  186.    * Access the image animation mode for this context
  187.    */
  188.   PRUint16     ImageAnimationMode() const { return mImageAnimationMode; }
  189.   virtual NS_HIDDEN_(void) SetImageAnimationModeExternal(PRUint16 aMode);
  190.   NS_HIDDEN_(void) SetImageAnimationModeInternal(PRUint16 aMode);
  191. #ifdef _IMPL_NS_LAYOUT
  192.   void SetImageAnimationMode(PRUint16 aMode)
  193.   { SetImageAnimationModeInternal(aMode); }
  194. #else
  195.   void SetImageAnimationMode(PRUint16 aMode)
  196.   { SetImageAnimationModeExternal(aMode); }
  197. #endif
  198.  
  199.   /**
  200.    * Get cached look and feel service.  This is faster than obtaining it
  201.    * through the service manager.
  202.    */
  203.   nsILookAndFeel* LookAndFeel() { return mLookAndFeel; }
  204.  
  205.   /** 
  206.    * Get medium of presentation
  207.    */
  208.   nsIAtom* Medium() { return mMedium; }
  209.  
  210.   /**
  211.    * Clear style data from the root frame downwards, and reflow.
  212.    */
  213.   NS_HIDDEN_(void) ClearStyleDataAndReflow();
  214.  
  215.   void* AllocateFromShell(size_t aSize)
  216.   {
  217.     if (mShell)
  218.       return mShell->AllocateFrame(aSize);
  219.     return nsnull;
  220.   }
  221.  
  222.   void FreeToShell(size_t aSize, void* aFreeChunk)
  223.   {
  224.     if (mShell)
  225.       mShell->FreeFrame(aSize, aFreeChunk);
  226.   }
  227.  
  228.   /**
  229.    * Get the font metrics for a given font.
  230.    */
  231.   virtual NS_HIDDEN_(already_AddRefed<nsIFontMetrics>)
  232.    GetMetricsForExternal(const nsFont& aFont);
  233.   NS_HIDDEN_(already_AddRefed<nsIFontMetrics>)
  234.     GetMetricsForInternal(const nsFont& aFont);
  235. #ifdef _IMPL_NS_LAYOUT
  236.   already_AddRefed<nsIFontMetrics> GetMetricsFor(const nsFont& aFont)
  237.   { return GetMetricsForInternal(aFont); }
  238. #else
  239.   already_AddRefed<nsIFontMetrics> GetMetricsFor(const nsFont& aFont)
  240.   { return GetMetricsForExternal(aFont); }
  241. #endif
  242.  
  243.   /**
  244.    * Get the default font correponding to the given ID.  This object is
  245.    * read-only, you must copy the font to modify it.
  246.    */
  247.   virtual NS_HIDDEN_(const nsFont*) GetDefaultFontExternal(PRUint8 aFontID) const;
  248.   NS_HIDDEN_(const nsFont*) GetDefaultFontInternal(PRUint8 aFontID) const;
  249. #ifdef _IMPL_NS_LAYOUT
  250.   const nsFont* GetDefaultFont(PRUint8 aFontID) const
  251.   { return GetDefaultFontInternal(aFontID); }
  252. #else
  253.   const nsFont* GetDefaultFont(PRUint8 aFontID) const
  254.   { return GetDefaultFontExternal(aFontID); }
  255. #endif
  256.  
  257.   /** Get a cached boolean pref, by its type */
  258.   // *  - initially created for bugs 31816, 20760, 22963
  259.   PRBool GetCachedBoolPref(PRUint32 aPrefType) const
  260.   {
  261.     // If called with a constant parameter, the compiler should optimize
  262.     // this switch statement away.
  263.     switch (aPrefType) {
  264.     case kPresContext_UseDocumentFonts:
  265.       return mUseDocumentFonts;
  266.     case kPresContext_UseDocumentColors:
  267.       return mUseDocumentColors;
  268.     case kPresContext_UnderlineLinks:
  269.       return mUnderlineLinks;
  270.     default:
  271.       NS_ERROR("Invalid arg passed to GetCachedBoolPref");
  272.     }
  273.  
  274.     return PR_FALSE;
  275.   }
  276.  
  277.   /** Get a cached integer pref, by its type */
  278.   // *  - initially created for bugs 30910, 61883, 74186, 84398
  279.   PRInt32 GetCachedIntPref(PRUint32 aPrefType) const
  280.   {
  281.     // If called with a constant parameter, the compiler should optimize
  282.     // this switch statement away.
  283.     switch (aPrefType) {
  284.     case kPresContext_MinimumFontSize:
  285.       return mMinimumFontSize;
  286.     default:
  287.       NS_ERROR("invalid arg passed to GetCachedIntPref");
  288.     }
  289.  
  290.     return PR_FALSE;
  291.   }
  292.  
  293.   /**
  294.    * Access Nav's magic font scaler value
  295.    */
  296.   PRInt32 FontScaler() const { return mFontScaler; }
  297.  
  298.   /** 
  299.    * Get the default colors
  300.    */
  301.   const nscolor DefaultColor() const { return mDefaultColor; }
  302.   const nscolor DefaultBackgroundColor() const { return mBackgroundColor; }
  303.   const nscolor DefaultLinkColor() const { return mLinkColor; }
  304.   const nscolor DefaultActiveLinkColor() const { return mActiveLinkColor; }
  305.   const nscolor DefaultVisitedLinkColor() const { return mVisitedLinkColor; }
  306.   const nscolor FocusBackgroundColor() const { return mFocusBackgroundColor; }
  307.   const nscolor FocusTextColor() const { return mFocusTextColor; }
  308.  
  309.   PRBool GetUseFocusColors() const { return mUseFocusColors; }
  310.   PRUint8 FocusRingWidth() const { return mFocusRingWidth; }
  311.   PRBool GetFocusRingOnAnything() const { return mFocusRingOnAnything; }
  312.  
  313.  
  314.   /**
  315.    * Load an image for the target frame. This call can be made
  316.    * repeated with only a single image ever being loaded. When the
  317.    * image's data is ready for rendering the target frame's Paint()
  318.    * method will be invoked (via the ViewManager) so that the
  319.    * appropriate damage repair is done.
  320.    */
  321.   NS_HIDDEN_(imgIRequest*) LoadImage(imgIRequest* aImage,
  322.                                      nsIFrame* aTargetFrame);
  323.  
  324.   /**
  325.    * This method is called when a frame is being destroyed to
  326.    * ensure that the image load gets disassociated from the prescontext
  327.    */
  328.   NS_HIDDEN_(void) StopImagesFor(nsIFrame* aTargetFrame);
  329.  
  330.   NS_HIDDEN_(void) SetContainer(nsISupports* aContainer);
  331.  
  332.   virtual NS_HIDDEN_(already_AddRefed<nsISupports>) GetContainerExternal();
  333.   NS_HIDDEN_(already_AddRefed<nsISupports>) GetContainerInternal();
  334. #ifdef _IMPL_NS_LAYOUT
  335.   already_AddRefed<nsISupports> GetContainer()
  336.   { return GetContainerInternal(); }
  337. #else
  338.   already_AddRefed<nsISupports> GetContainer()
  339.   { return GetContainerExternal(); }
  340. #endif
  341.  
  342.   // XXX this are going to be replaced with set/get container
  343.   void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; }
  344.   nsILinkHandler* GetLinkHandler() { return mLinkHandler; }
  345.  
  346.   /**
  347.    * Get the visible area associated with this presentation context.
  348.    * This is the size of the visiable area that is used for
  349.    * presenting the document. The returned value is in the standard
  350.    * nscoord units (as scaled by the device context).
  351.    */
  352.   nsRect GetVisibleArea() { return mVisibleArea; }
  353.  
  354.   /**
  355.    * Set the currently visible area. The units for r are standard
  356.    * nscoord units (as scaled by the device context).
  357.    */
  358.   void SetVisibleArea(const nsRect& r) { mVisibleArea = r; }
  359.  
  360.   /**
  361.    * Return true if this presentation context is a paginated
  362.    * context.
  363.    */
  364.   PRBool IsPaginated() const { return mPaginated; }
  365.  
  366.   /**
  367.    * Sets whether the presentation context can scroll for a paginated
  368.    * context.
  369.    */
  370.   NS_HIDDEN_(void) SetPaginatedScrolling(PRBool aResult);
  371.  
  372.   /**
  373.    * Return true if this presentation context can scroll for paginated
  374.    * context.
  375.    */
  376.   PRBool HasPaginatedScrolling() const { return mCanPaginatedScroll; }
  377.  
  378.   /**
  379.    * Gets the rect for the page dimensions,
  380.    * this includes X,Y Offsets which are used to determine 
  381.    * the inclusion of margins
  382.    * Also, indicates whether the size has been overridden
  383.    *
  384.    * @param aActualRect returns the size of the actual device/surface
  385.    * @param aRect returns the adjusted size 
  386.    */
  387.   NS_HIDDEN_(void) GetPageDim(nsRect* aActualRect, nsRect* aAdjRect);
  388.  
  389.   /**
  390.    * Sets the "adjusted" rect for the page Dimimensions, 
  391.    * this includes X,Y Offsets which are used to determine 
  392.    * the inclusion of margins
  393.    *
  394.    * @param aRect returns the adjusted size 
  395.    */
  396.   NS_HIDDEN_(void) SetPageDim(const nsRect& aRect);
  397.  
  398.   float PixelsToTwips() const { return mDeviceContext->DevUnitsToAppUnits(); }
  399.  
  400.   float TwipsToPixels() const { return mDeviceContext->AppUnitsToDevUnits(); }
  401.  
  402.   NS_HIDDEN_(float) TwipsToPixelsForFonts() const;
  403.  
  404.   //XXX this is probably not an ideal name. MMP
  405.   /** 
  406.    * Do pixels to twips conversion taking into account
  407.    * differing size of a "pixel" from device to device.
  408.    */
  409.   NS_HIDDEN_(float) ScaledPixelsToTwips() const;
  410.  
  411.   /* Convenience method for converting one pixel value to twips */
  412.   nscoord IntScaledPixelsToTwips(nscoord aPixels) const
  413.   { return NSIntPixelsToTwips(aPixels, ScaledPixelsToTwips()); }
  414.  
  415.   /* Set whether twip scaling is used */
  416.   void SetScalingOfTwips(PRBool aOn) { mDoScaledTwips = aOn; }
  417.  
  418.   nsIDeviceContext* DeviceContext() { return mDeviceContext; }
  419.   nsIEventStateManager* EventStateManager() { return mEventManager; }
  420.   nsIAtom* GetLangGroup() { return mLangGroup; }
  421.  
  422.   float TextZoom() { return mTextZoom; }
  423.   void SetTextZoomInternal(float aZoom) {
  424.     mTextZoom = aZoom;
  425.     ClearStyleDataAndReflow();
  426.   }
  427.   virtual NS_HIDDEN_(void) SetTextZoomExternal(float aZoom);
  428. #ifdef _IMPL_NS_LAYOUT
  429.   void SetTextZoom(float aZoom) { SetTextZoomInternal(aZoom); }
  430. #else
  431.   void SetTextZoom(float aZoom) { SetTextZoomExternal(aZoom); }
  432. #endif
  433.  
  434.  
  435.  
  436.   /**
  437.    * Get the language-specific transform type for the current document.
  438.    * This tells us whether we need to perform special language-dependent
  439.    * transformations such as Unicode U+005C (backslash) to Japanese
  440.    * Yen Sign (Unicode U+00A5, JIS 0x5C).
  441.    *
  442.    * @param aType returns type, must be non-NULL
  443.    */
  444.   nsLanguageSpecificTransformType LanguageSpecificTransformType() const
  445.   {
  446.     return mLanguageSpecificTransformType;
  447.   }
  448.  
  449.   struct ScrollbarStyles {
  450.     // Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
  451.     // or NS_STYLE_OVERFLOW_AUTO.
  452.     PRUint8 mHorizontal, mVertical;
  453.     ScrollbarStyles(PRUint8 h, PRUint8 v) : mHorizontal(h), mVertical(v) {}
  454.     ScrollbarStyles() {}
  455.   };
  456.   void SetViewportOverflowOverride(PRUint8 aX, PRUint8 aY)
  457.   {
  458.     mViewportStyleOverflow.mHorizontal = aX;
  459.     mViewportStyleOverflow.mVertical = aY;
  460.   }
  461.   ScrollbarStyles GetViewportOverflowOverride()
  462.   {
  463.     return mViewportStyleOverflow;
  464.   }
  465.  
  466.   /**
  467.    * Set and get methods for controling the background drawing
  468.   */
  469.   PRBool GetBackgroundImageDraw() const { return mDrawImageBackground; }
  470.   void   SetBackgroundImageDraw(PRBool aCanDraw)
  471.   {
  472.     NS_ASSERTION(!(aCanDraw & ~1), "Value must be true or false");
  473.     mDrawImageBackground = aCanDraw;
  474.   }
  475.  
  476.   PRBool GetBackgroundColorDraw() const { return mDrawColorBackground; }
  477.   void   SetBackgroundColorDraw(PRBool aCanDraw)
  478.   {
  479.     NS_ASSERTION(!(aCanDraw & ~1), "Value must be true or false");
  480.     mDrawColorBackground = aCanDraw;
  481.   }
  482.  
  483. #ifdef IBMBIDI
  484.   /**
  485.    *  Check if bidi enabled (set depending on the presence of RTL
  486.    *  characters or when default directionality is RTL).
  487.    *  If enabled, we should apply the Unicode Bidi Algorithm
  488.    *
  489.    *  @lina 07/12/2000
  490.    */
  491.   virtual NS_HIDDEN_(PRBool) BidiEnabledExternal() const;
  492.   NS_HIDDEN_(PRBool) BidiEnabledInternal() const;
  493. #ifdef _IMPL_NS_LAYOUT
  494.   PRBool BidiEnabled() const { return BidiEnabledInternal(); }
  495. #else
  496.   PRBool BidiEnabled() const { return BidiEnabledExternal(); }
  497. #endif
  498.  
  499.   /**
  500.    *  Set bidi enabled. This means we should apply the Unicode Bidi Algorithm
  501.    *
  502.    *  @lina 07/12/2000
  503.    */
  504.   NS_HIDDEN_(void) SetBidiEnabled(PRBool aBidiEnabled) const;
  505.  
  506.   /**
  507.    *  Set visual or implicit mode into the pres context.
  508.    *
  509.    *  Visual directionality is a presentation method that displays text
  510.    *  as if it were a uni-directional, according to the primary display
  511.    *  direction only. 
  512.    *
  513.    *  Implicit directionality is a presentation method in which the
  514.    *  direction is determined by the Bidi algorithm according to the
  515.    *  category of the characters and the category of the adjacent
  516.    *  characters, and according to their primary direction.
  517.    *
  518.    *  @lina 05/02/2000
  519.    */
  520.   void SetVisualMode(PRBool aIsVisual)
  521.   {
  522.     NS_ASSERTION(!(aIsVisual & ~1), "Value must be true or false");
  523.     mIsVisual = aIsVisual;
  524.   }
  525.  
  526.   /**
  527.    *  Check whether the content should be treated as visual.
  528.    *
  529.    *  @lina 05/02/2000
  530.    */
  531.   PRBool IsVisualMode() const { return mIsVisual; }
  532.  
  533. //Mohamed
  534.  
  535.   /**
  536.    * Get a Bidi presentation utilities object
  537.    */
  538.   NS_HIDDEN_(nsBidiPresUtils*) GetBidiUtils();
  539.  
  540.   /**
  541.    * Set the Bidi options for the presentation context
  542.    */  
  543.   NS_HIDDEN_(void) SetBidi(PRUint32 aBidiOptions,
  544.                            PRBool aForceReflow = PR_FALSE);
  545.  
  546.   /**
  547.    * Get the Bidi options for the presentation context
  548.    */  
  549.   NS_HIDDEN_(PRUint32) GetBidi() const { return mBidi; }
  550.  
  551.   /**
  552.    * Set the Bidi capabilities of the system
  553.    * @param aIsBidi == TRUE if the system has the capability of reordering Bidi text
  554.    */
  555.   void SetIsBidiSystem(PRBool aIsBidi)
  556.   {
  557.     NS_ASSERTION(!(aIsBidi & ~1), "Value must be true or false");
  558.     mIsBidiSystem = aIsBidi;
  559.   }
  560.  
  561.   /**
  562.    * Get the Bidi capabilities of the system
  563.    * @return TRUE if the system has the capability of reordering Bidi text
  564.    */
  565.   PRBool IsBidiSystem() const { return mIsBidiSystem; }
  566. #endif // IBMBIDI
  567.  
  568.   /**
  569.    * Render only Selection
  570.    */
  571.   void SetIsRenderingOnlySelection(PRBool aResult)
  572.   {
  573.     NS_ASSERTION(!(aResult & ~1), "Value must be true or false");
  574.     mIsRenderingOnlySelection = aResult;
  575.   }
  576.  
  577.   PRBool IsRenderingOnlySelection() const { return mIsRenderingOnlySelection; }
  578.  
  579.   /*
  580.    * Obtain a native them for rendering our widgets (both form controls and html)
  581.    */
  582.   NS_HIDDEN_(nsITheme*) GetTheme();
  583.  
  584.   /*
  585.    * Notify the pres context that the theme has changed.  An internal switch
  586.    * means it's one of our Mozilla themes that changed (e.g., Modern to Classic).
  587.    * Otherwise, the OS is telling us that the native theme for the platform
  588.    * has changed.
  589.    */
  590.   NS_HIDDEN_(void) ThemeChanged();
  591.  
  592.   /*
  593.    * Notify the pres context that a system color has changed
  594.    */
  595.   NS_HIDDEN_(void) SysColorChanged();
  596.  
  597.   /** Printing methods below should only be used for Medium() == print **/
  598.   NS_HIDDEN_(void) SetPrintSettings(nsIPrintSettings *aPrintSettings);
  599.  
  600.   nsIPrintSettings* GetPrintSettings() { return mPrintSettings; }
  601.  
  602.   /* Accessor for table of frame properties */
  603.   nsPropertyTable* PropertyTable() { return &mPropertyTable; }
  604.  
  605.   /* Helper function that ensures that this prescontext is shown in its
  606.      docshell if it's the most recent prescontext for the docshell.  Returns
  607.      whether the prescontext is now being shown.
  608.  
  609.      @param aUnsuppressFocus If this is false, then focus will not be
  610.      unsuppressed when PR_TRUE is returned.  It's the caller's responsibility
  611.      to unsuppress focus in that case.
  612.   */
  613.   NS_HIDDEN_(PRBool) EnsureVisible(PRBool aUnsuppressFocus);
  614.   
  615. #ifdef MOZ_REFLOW_PERF
  616.   NS_HIDDEN_(void) CountReflows(const char * aName,
  617.                                 PRUint32 aType, nsIFrame * aFrame);
  618.   NS_HIDDEN_(void) PaintCount(const char * aName,
  619.                               nsIRenderingContext* aRendingContext,
  620.                               nsIFrame * aFrame, PRUint32 aColor);
  621. #endif
  622.  
  623.   /**
  624.    * This table maps border-width enums 'thin', 'medium', 'thick'
  625.    * to actual nscoord values.
  626.    */
  627.   const nscoord* GetBorderWidthTable() { return mBorderWidthTable; }
  628.  
  629. protected:
  630.   NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, PRUint16 aMode);
  631.   NS_HIDDEN_(void) GetDocumentColorPreferences();
  632.  
  633.   NS_HIDDEN_(void) PreferenceChanged(const char* aPrefName);
  634.   static NS_HIDDEN_(int) PR_CALLBACK PrefChangedCallback(const char*, void*);
  635.  
  636.   NS_HIDDEN_(void) UpdateAfterPreferencesChanged();
  637.   static NS_HIDDEN_(void) PR_CALLBACK PrefChangedUpdateTimerCallback(nsITimer *aTimer, void *aClosure);
  638.  
  639.   NS_HIDDEN_(void) GetUserPreferences();
  640.   NS_HIDDEN_(void) GetFontPreferences();
  641.  
  642.   NS_HIDDEN_(void) UpdateCharSet(const nsAFlatCString& aCharSet);
  643.  
  644.   // IMPORTANT: The ownership implicit in the following member variables
  645.   // has been explicitly checked.  If you add any members to this class,
  646.   // please make the ownership explicit (pinkerton, scc).
  647.   
  648.   nsPresContextType     mType;
  649.   nsIPresShell*         mShell;         // [WEAK]
  650.   nsIDeviceContext*     mDeviceContext; // [STRONG] could be weak, but
  651.                                         // better safe than sorry.
  652.                                         // Cannot reintroduce cycles
  653.                                         // since there is no dependency
  654.                                         // from gfx back to layout.
  655.   nsIEventStateManager* mEventManager;  // [STRONG]
  656.   nsILookAndFeel*       mLookAndFeel;   // [STRONG]
  657.   nsIAtom*              mMedium;        // initialized by subclass ctors;
  658.                                         // weak pointer to static atom
  659.  
  660.   nsILinkHandler*       mLinkHandler;   // [WEAK]
  661.   nsIAtom*              mLangGroup;     // [STRONG]
  662.  
  663.   nsSupportsHashtable   mImageLoaders;
  664.   nsWeakPtr             mContainer;
  665.  
  666.   float                 mTextZoom;      // Text zoom, defaults to 1.0
  667.  
  668. #ifdef IBMBIDI
  669.   nsBidiPresUtils*      mBidiUtils;
  670. #endif
  671.  
  672.   nsCOMPtr<nsITheme> mTheme;
  673.   nsCOMPtr<nsILanguageAtomService> mLangService;
  674.   nsCOMPtr<nsIPrintSettings> mPrintSettings;
  675.   nsCOMPtr<nsITimer>    mPrefChangedTimer;
  676.  
  677.   nsPropertyTable       mPropertyTable;
  678.  
  679.   nsLanguageSpecificTransformType mLanguageSpecificTransformType;
  680.   PRInt32               mFontScaler;
  681.   nscoord               mMinimumFontSize;
  682.  
  683.   nsRect                mVisibleArea;
  684.   nsRect                mPageDim;
  685.  
  686.   nscolor               mDefaultColor;
  687.   nscolor               mBackgroundColor;
  688.  
  689.   nscolor               mLinkColor;
  690.   nscolor               mActiveLinkColor;
  691.   nscolor               mVisitedLinkColor;
  692.  
  693.   nscolor               mFocusBackgroundColor;
  694.   nscolor               mFocusTextColor;
  695.  
  696.   ScrollbarStyles       mViewportStyleOverflow;
  697.   PRUint8               mFocusRingWidth;
  698.  
  699.   nsCompatibility       mCompatibilityMode;
  700.   PRUint16              mImageAnimationMode;
  701.   PRUint16              mImageAnimationModePref;
  702.  
  703.   nsFont                mDefaultVariableFont;
  704.   nsFont                mDefaultFixedFont;
  705.   nsFont                mDefaultSerifFont;
  706.   nsFont                mDefaultSansSerifFont;
  707.   nsFont                mDefaultMonospaceFont;
  708.   nsFont                mDefaultCursiveFont;
  709.   nsFont                mDefaultFantasyFont;
  710.  
  711.   nscoord               mBorderWidthTable[3];
  712.  
  713.   unsigned              mUseDocumentFonts : 1;
  714.   unsigned              mUseDocumentColors : 1;
  715.   unsigned              mUnderlineLinks : 1;
  716.   unsigned              mUseFocusColors : 1;
  717.   unsigned              mFocusRingOnAnything : 1;
  718.   unsigned              mDrawImageBackground : 1;
  719.   unsigned              mDrawColorBackground : 1;
  720.   unsigned              mNeverAnimate : 1;
  721.   unsigned              mIsRenderingOnlySelection : 1;
  722.   unsigned              mNoTheme : 1;
  723.   unsigned              mPaginated : 1;
  724.   unsigned              mCanPaginatedScroll : 1;
  725.   unsigned              mDoScaledTwips : 1;
  726.   unsigned              mEnableJapaneseTransform : 1;
  727. #ifdef IBMBIDI
  728.   unsigned              mIsVisual : 1;
  729.   unsigned              mIsBidiSystem : 1;
  730.  
  731.   PRUint32              mBidi;
  732. #endif
  733. #ifdef DEBUG
  734.   PRBool                mInitialized;
  735. #endif
  736.  
  737.  
  738. protected:
  739.  
  740.   ~nsPresContext() NS_HIDDEN;
  741.  
  742.   // these are private, use the list in nsFont.h if you want a public list
  743.   enum {
  744.     eDefaultFont_Variable,
  745.     eDefaultFont_Fixed,
  746.     eDefaultFont_Serif,
  747.     eDefaultFont_SansSerif,
  748.     eDefaultFont_Monospace,
  749.     eDefaultFont_Cursive,
  750.     eDefaultFont_Fantasy,
  751.     eDefaultFont_COUNT
  752.   };
  753.  
  754. };
  755.  
  756. // Bit values for StartLoadImage's aImageStatus
  757. #define NS_LOAD_IMAGE_STATUS_ERROR      0x1
  758. #define NS_LOAD_IMAGE_STATUS_SIZE       0x2
  759. #define NS_LOAD_IMAGE_STATUS_BITS       0x4
  760.  
  761. #ifdef MOZ_REFLOW_PERF
  762.  
  763. #define DO_GLOBAL_REFLOW_COUNT(_name, _type) \
  764.   aPresContext->CountReflows((_name), (_type), (nsIFrame*)this); 
  765. #else
  766. #define DO_GLOBAL_REFLOW_COUNT(_name, _type)
  767. #endif // MOZ_REFLOW_PERF
  768.  
  769. #if defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF)
  770. #define DO_GLOBAL_REFLOW_COUNT_DSP(_name, _rend) \
  771.   if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { \
  772.     aPresContext->PaintCount((_name), (_rend), (nsIFrame*)this, 0); \
  773.   }
  774. #define DO_GLOBAL_REFLOW_COUNT_DSP_J(_name, _rend, _just) \
  775.   if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { \
  776.     aPresContext->PaintCount((_name), (_rend), (nsIFrame*)this, (_just)); \
  777.   }
  778. #else
  779. #define DO_GLOBAL_REFLOW_COUNT_DSP(_name, _rend)
  780. #define DO_GLOBAL_REFLOW_COUNT_DSP_J(_name, _rend, _just)
  781. #endif // MOZ_REFLOW_PERF_DSP
  782.  
  783. #endif /* nsPresContext_h___ */
  784.